<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"

      xmlns:f="http://java.sun.com/jsf/core" xmlns:c="http://java.sun.com/jsp/jstl/core">
    <ui:composition template="TaskProLayout.xhtml">
        <ui:define name="content">
            <div class="Post">
                <h:form id="taskInfo">        
                    <h:panelGrid id="taskConfimGrid" columns="2" cellpadding="4" title="Original Task">  
                        <h:outputText value="Label"/>
                        <h:outputText value="#{studentTaskBean.taskChoosen.template.name}" />
                        <h:outputText value="Description"/>
                        <h:outputText value="#{studentTaskBean.taskChoosen.template.description}" escape="false" >
                             <f:converter converterId="StringFormatter"/>
                        </h:outputText>
                        <h:outputText value="Deadline"/>
                        <h:outputText value="#{studentTaskBean.taskChoosen.deadline}" >
                            <f:convertDateTime type="both" timeZone="Europe/Prague"></f:convertDateTime>
                        </h:outputText>
                        <h:outputText value="Date of assignment"/>
                        <h:outputText value="#{studentTaskBean.taskChoosen.dateOfAssignment}" >
                            <f:convertDateTime type="both" timeZone="Europe/Prague"></f:convertDateTime>
                        </h:outputText>
                         <h:outputText value="Date of visible"/>
                         <h:outputText value="#{studentTaskBean.taskChoosen.dateOfStart}" >
                            <f:convertDateTime type="both" timeZone="Europe/Prague"></f:convertDateTime>
                        </h:outputText>
                    </h:panelGrid> 
                                        <p:notificationBar position="top" effect="slide"  widgetVar="bar" styleClass="top">  
                        <h:outputText value="System start with sending your task this action could take a few second." style="color:#FFCC00;font-size:36px;" />  
                    </p:notificationBar>  
                    <p:commandButton action="#{studentTaskBean.sendTask()}"  value="Submit task" onclick="bar.show()" oncomplete="bar.hide()" ajax="false"  />
                </h:form>
            </div>
            <div class="Post">
                <h2>Files to submit</h2>
                <h:form id="fileSubmit">
                    <p:dataTable var="taskFile" value="#{studentTaskBean.versionOfTask.getmVersionFiles()}" 
                                 id="files" rowKey="#{taskFile.id}" >  
                        <f:facet name="header">
                            <h:outputText value="Files to submit" />
                        </f:facet>
                        <p:column headerText="Name" >              
                            <h:outputText value="#{taskFile.fileName}" >
                                <f:converter converterId="StringConverter" />
                            </h:outputText>
                        </p:column>
                        <p:column headerText="Size" >              
                            <h:outputText value="#{taskFile.fileSize}" >
                            </h:outputText>
                        </p:column>
                        <p:column headerText="Description">  
                            <p:cellEditor>  
                                <f:facet name="output">  
                                    <h:outputText value="#{taskFile.description}" >
                                        <f:converter converterId="StringConverter" />
                                    </h:outputText>
                                </f:facet>  
                                <f:facet name="input">  
                                    <p:inputTextarea value="#{taskFile.description}" style="width:100%"/>  
                                </f:facet>  
                            </p:cellEditor>  
                        </p:column>  
                        <p:column headerText="Action">
                            <p:commandButton value="Download" ajax="false">
                                <p:fileDownload id="koko" value="#{studentTaskBean.downloadFilesByTask(taskFile)}"/>
                            </p:commandButton>
                            <p:commandButton value="Remove" ajax="false"  update=":assignmentFile:assignmentFileTable"  action="#{studentTaskBean.removeFile(taskFile)}"/>
                        </p:column>
                        <p:column headerText="Options">  
                            <p:rowEditor />  
                        </p:column>  
                        <f:facet name="footer">
                            <h:outputText value=" " />
                        </f:facet>
                    </p:dataTable>
                </h:form>
            </div>
            <div class="Post">
                <h2>Files uploader</h2>
                <h:form id="fileUpload" enctype="multipart/form-data" prependId="false">   
                    <h:outputLabel for="Upload" value="Upload file (pdf,zip,java)" />
                    <p:fileUpload  id="Upload" sizeLimit="16777216"  multiple="true"  fileUploadListener="#{studentTaskBean.uploadFile}" allowTypes="/(\.|\/)(pdf|zip|java|gz)$/" 
                                   mode="advanced"  update=":fileSubmit:files" />             
                </h:form>  
            </div>
         
        </ui:define>
    </ui:composition>



</html>